require "Dialogs"

Black = CreateSprite("Pixel","Top")
Black.Scale(640, 480)
Black.color = {0,0,0}
Black.MoveTo(320, 240)

timer = 0

function Update()
	DialogUpdate()
	if timer == 0 then
		if not Logo then
			Logo = CreateSprite("Menu/Disbelief","Top")
			Logo.Scale(300/826, 300/826)
			Logo.alpha = 0
		else
			Logo.alpha = Logo.alpha + 0.004
			Logo.Scale(Logo.xscale + 0.5/826, Logo.yscale + 0.5/826)
			if Logo.xscale > 500/826 then
				Audio.PlaySound("suspenso")
				Logo.Remove()
				Logo = nil
				Me = CreateSprite("Credits/"..GetAlMightyGlobal("Idioma").."/Cezar","Top")
				Me.MoveTo(320, 240)
				timer = 1
			end
		end
	elseif timer >= 1 and timer < 570 then
		timer = timer + 1
		if not Flames then
			Flames = CreateSprite("Credits/"..GetAlMightyGlobal("Idioma").."/Flames","Top")
			Flames.MoveTo(320, 240)
			Flames.alpha = 0
			Me.SendToTop()
		end
		if timer > 120 and timer <= 210 then
			Me.MoveTo(245 + 75*math.cos(math.rad(180/90*(timer - 120))), 240)
			Flames.MoveTo(395 - 75*math.cos(math.rad(180/90*(timer - 120))), 240)
			Flames.alpha = 0.5 - 0.5*math.cos(math.rad(180/90*(timer - 120)))
		end
	elseif timer == 570 then
		Audio.PlaySound("suspenso")
		Me.Remove()
		Flames.Remove()
		Me = nil
		Flames = nil
		timer = 571
	elseif timer >= 571 and timer < 810 then
		timer = timer + 1
	elseif timer == 810 then
		Audio.PlaySound("ring")
		timer = timer + 1
	elseif timer > 810 and timer < 870 then
		timer = timer + 1
	elseif timer == 870 then
		Box("[noskip][voice:monster](Ring[w:10], ring...)", "", "", "", 0, 80, nil, "", 1)
		timer = 871
	elseif timer == 871 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Nyeh 2]Hola?[StopAnimation][SetCara:Nyeh 1]", "papyrus", "Nyeh 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Nyeh 2]Hello?[StopAnimation][SetCara:Nyeh 1]", "papyrus", "Nyeh 1", "", 0, 80, nil, "", 1)
		end
		timer = 872
	elseif timer == 872 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]Hay[StopAnimation][SetCara:Worried 1][w:4].[w:4].[w:4].[w:4][SetAnimation:Worried 2] alguien ahí?[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]Is[StopAnimation][SetCara:Worried 1][w:4].[w:4].[w:4].[w:4][SetAnimation:Worried 2] anyone there?[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		end
		timer = 873
	elseif timer == 873 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Thinking 2]Bueno[StopAnimation][SetCara:Thinking 1][w:10][SetAnimation:Thinking 2], Supongo\rque solo dejaré\run mensaje.[StopAnimation][SetCara:Thinking 1]", "papyrus", "Thinking 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Thinking 2]Well[StopAnimation][SetCara:Thinking 1][w:10][SetAnimation:Thinking 2], I guess I'll\rjust leave a\rmessage.[StopAnimation][SetCara:Thinking 1]", "papyrus", "Thinking 1", "", 0, 80, nil, "", 1)
		end
		timer = 874
	elseif timer == 874 and Boxes[1] and not Boxes[1].Activo then
		NewAudio.PlaySound("Loop", "Goodnight", true, 1)
		timer = 875
	elseif timer > 874 and timer <= 994 then
		timer = timer + 1
		if not Text then
			Text = CreateSprite("Credits/"..GetAlMightyGlobal("Idioma").."/Thanks", "Top")
			Text.MoveTo(320, 300)
		end
		Text.alpha = 1/120*(timer - 874)
	elseif timer == 995 then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Nyeh 2]Así que[StopAnimation][SetCara:Nyeh 1][w:10][SetAnimation:Nyeh 2], ha estado\rmuy solitario aquí\ren el subsuelo.[StopAnimation][SetCara:Nyeh 1]", "papyrus", "Nyeh 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Nyeh 2]So[StopAnimation][SetCara:Nyeh 1][w:10][SetAnimation:Nyeh 2], It's been quite\rlonely here in the\runderground.[StopAnimation][SetCara:Nyeh 1]", "papyrus", "Nyeh 1", "", 0, 80, nil, "", 1)
		end
		timer = 996
	elseif timer == 996 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Thinking 2]El rey desapareció\rjunto con las seis\ralmas humanas.[StopAnimation][SetCara:Thinking 1]", "papyrus", "Thinking 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Thinking 2]The king vanished\ralong with the six\rhuman souls.[StopAnimation][SetCara:Thinking 1]", "papyrus", "Thinking 1", "", 0, 80, nil, "", 1)
		end
		timer = 997
	elseif timer == 997 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]Y undyne.[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]And undyne.[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		end
		timer = 998
	elseif timer == 998 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][waittall:4]...[waittall:1][SetAnimation:Scared 2]y mettaton.[StopAnimation][SetCara:Scared 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][waittall:4]...[waittall:1][SetAnimation:Scared 2]and mettaton.[StopAnimation][SetCara:Scared 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		end
		timer = 999
	elseif timer == 999 and Boxes[1] and not Boxes[1].Activo then
		Box("[noskip][voice:papyrus]. . .", "papyrus", "Sad", "", 0, 80, nil, "", 1)
		timer = 1000
	elseif timer == 1000 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Nyeh 2]A-[StopAnimation][SetCara:Nyeh 1][w:10][SetCara:Normal 1][SetAnimation:Normal 2]aunque eso está\rbien![StopAnimation][SetCara:Normal 1]", "papyrus", "Nyeh 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Nyeh 2]Th-[StopAnimation][SetCara:Nyeh 1][w:10][SetCara:Normal 1][SetAnimation:Normal 2]That's okay[StopAnimation][SetCara:Normal 1][w:10][SetAnimation:Normal 2],\rthough![StopAnimation][SetCara:Normal 1]", "papyrus", "Nyeh 1", "", 0, 80, nil, "", 1)
		end
		timer = 1001
	elseif timer == 1001 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]Soy un gran\ranimador![StopAnimation][SetCara:Normal 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]I'm a great\rentertainer![StopAnimation][SetCara:Normal 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		end
		timer = 1002
	elseif timer == 1002 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]Por eso ahora soy\rel rey![StopAnimation][SetCara:Normal 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]That's why I'm now\rthe king![StopAnimation][SetCara:Normal 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		end
		timer = 1003
	elseif timer == 1003 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]Incluso mejor que\run simple [StopAnimation][SetCara:Nyeh 1][SetAnimation:Nyeh 2]guardia\r[StopAnimation][SetCara:Worried 1][SetAnimation:Worried 2][waittall:3]real[StopAnimation][SetCara:Sad][waittall:6]...", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]Even better than\ra mere [StopAnimation][SetCara:Nyeh 1][SetAnimation:Nyeh 2]royal\r[StopAnimation][SetCara:Worried 1][SetAnimation:Worried 2][waittall:3]guardsman[StopAnimation][SetCara:Sad][waittall:6]...", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		end
		timer = 1004
	elseif timer == 1004 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]Hago lo mejor de\rmí para dar a mi\rgente esperanza.[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]I try my best to\rkeep filling my\rpeople with hope.[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		end
		timer = 1005
	elseif timer == 1005 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus]Para...", "papyrus", "Sad", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus]But...", "papyrus", "Sad", "", 0, 80, nil, "", 1)
		end
		timer = 1006
	elseif timer == 1006 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Scared 2]Es un trabajo\rbastante duro.[StopAnimation][SetCara:Scared 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Scared 2]It's quite a tough\rjob.[StopAnimation][SetCara:Scared 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		end
		timer = 1007
	elseif timer == 1007 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Scared 2]Incluso para\ralguien tan bueno\rcomo yo.[StopAnimation][SetCara:Scared 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Scared 2]Even for someone\ras great as me.[StopAnimation][SetCara:Scared 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		end
		timer = 1008
	elseif timer == 1008 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]He puesto en\rmarcha una nueva\rnueva regla![StopAnimation][SetCara:Normal 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]I've set in motion a\rnew rule![StopAnimation][SetCara:Normal 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		end
		timer = 1009
	elseif timer == 1009 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Angry 2]Cada humano que\rcaiga aquí.[StopAnimation][SetCara:Angry 1]", "papyrus", "Angry 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Angry 2]Every human that\rmay fall down\rhere.[StopAnimation][SetCara:Angry 1]", "papyrus", "Angry 1", "", 0, 80, nil, "", 1)
		end
		timer = 1010
	elseif timer == 1010 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Angry 2]No será\rtratado como\runa amenaza...[StopAnimation][SetCara:Angry 1]", "papyrus", "Angry 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Angry 2]Won't be treated\ras a threat...[StopAnimation][SetCara:Angry 1]", "papyrus", "Angry 1", "", 0, 80, nil, "", 1)
		end
		timer = 1011
	elseif timer == 1011 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]Sino como un\ramigo que debe\rser capturado.[StopAnimation][SetCara:Normal 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Normal 2]But as a friend\rwho must be\rcaptured.[StopAnimation][SetCara:Normal 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		end
		timer = 1012
	elseif timer == 1012 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:WTH 2]DESPUÉS DE HA-\rCERLOS RESOLVER\nMIS PUZZLES![StopAnimation][SetCara:WTH 1]", "papyrus", "WTH 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:WTH 2]AFTER MAKING THEM\rSOLVE MY PUZZLES![StopAnimation][SetCara:WTH 1]", "papyrus", "WTH 1", "", 0, 80, nil, "", 1)
		end
		timer = 1013
	elseif timer == 1013 and Boxes[1] and not Boxes[1].Activo then
		Box("[noskip][voice:papyrus][SetAnimation:Normal 2]NYEH HEH HEH HEH\rHEH HEH HEH...[StopAnimation][SetCara:Nyeh 1]", "papyrus", "Normal 1", "", 0, 80, nil, "", 1)
		timer = 1014
	elseif timer == 1014 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]Desearía que sans\rpuediera verme\rahora...[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]I wish sans could\rsee me now...[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		end
		timer = 1015
	elseif timer == 1015 and Boxes[1] and not Boxes[1].Activo then
		Box("[noskip][voice:papyrus]. . .", "papyrus", "Sad", "", 0, 80, nil, "", 1)
		timer = 1016
	elseif timer == 1016 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Scared 2]Pero h-[StopAnimation][SetCara:Scared 1][w:10][SetCara:Normal 1][SetAnimation:Normal 2]hey! [StopAnimation][SetCara:Normal 1][w:10][SetAnimation:Normal 2]no\rte preocupes![StopAnimation][SetCara:Normal 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Scared 2]But h-[StopAnimation][SetCara:Scared 1][w:10][SetCara:Normal 1][SetAnimation:Normal 2]hey! [StopAnimation][SetCara:Normal 1][w:10][SetAnimation:Normal 2]Don't\rworry![StopAnimation][SetCara:Normal 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		end
		timer = 1017
	elseif timer == 1017 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Angry 2]Ese flojo no se\rmolestaría en\rayudar.[StopAnimation][SetCara:Sad]", "papyrus", "Angry 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Angry 2]That lazybones\rwouldn't even\rbother to help.[StopAnimation][SetCara:Sad]", "papyrus", "Angry 1", "", 0, 80, nil, "", 1)
		end
		timer = 1018
	elseif timer == 1018 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Scared 2]Oh[StopAnimation][SetCara:Scared 1][w:10][SetAnimation:Scared 2], mi celular\rse está quedando\rsin batería.[StopAnimation][SetCara:Scared 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Scared 2]Oh[StopAnimation][SetCara:Scared 1][w:10][SetAnimation:Scared 2], my cellphone\ris running out of\rbattery.[StopAnimation][SetCara:Scared 1]", "papyrus", "Scared 1", "", 0, 80, nil, "", 1)
		end
		timer = 1019
	elseif timer == 1019 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Nyeh 2]No olvides\rllamarme cuando\rnecesites ayuda![StopAnimation][SetCara:Nyeh 1]", "papyrus", "Nyeh 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Nyeh 2]Don't forget to\rcall me whenever\ryou need help![StopAnimation][SetCara:Nyeh 1]", "papyrus", "Nyeh 1", "", 0, 80, nil, "", 1)
		end
		timer = 1020
	elseif timer == 1020 and Boxes[1] and not Boxes[1].Activo then
		if GetAlMightyGlobal("Idioma") == "Spanish" then
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]Adiós por ahora.[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		else
			Box("[noskip][voice:papyrus][SetAnimation:Worried 2]Good bye for now.[StopAnimation][SetCara:Worried 1]", "papyrus", "Worried 1", "", 0, 80, nil, "", 1)
		end
		timer = 1021
	elseif timer == 1021 and Boxes[1] and not Boxes[1].Activo then
		Box("[noskip][voice:monster](Click...)", "", "", "", 0, 80, nil, "", 1)
		timer = 1022
	elseif timer == 1022 and Boxes[1] and not Boxes[1].Activo then
		Encounter["GameMusic"] = "Fade"
		Encounter["Volumen"] = 1
		timer = 1023
	elseif timer > 1022 and timer < 1262 then
		timer = timer + 1
		if timer > 1142 then
			Text.alpha = 1/120*(1262 - timer)
		end
		if timer == 1262 then
			if string.sub(GetAlMightyGlobal("Archivimentazo"), 3, 3) == "0" then
				SetAlMightyGlobal("Archivimentazo", string.sub(GetAlMightyGlobal("Archivimentazo"), 1, 2).."1"..string.sub(GetAlMightyGlobal("Archivimentazo"), 4))
				Encounter["LogroDesbloqueado"] = {Timer = 0, Icon = 3}
			end
			Text.Remove()
			Text = nil
		end
	elseif timer >= 1262 and timer <= 1502 then
		timer = timer + 1
	elseif timer == 1503 then
		Black.Remove()
		SetAlMightyGlobal("ShortDialog", false)
		Encounter["nextwaves"] = {"Menu"}
		State("DEFENDING")
	end
end

function OnHit()
	
end